<?php include "../public/header.php";?>
<?php include "../public/header_edit.php";?>
<style>
    xm-select > .xm-body .scroll-body{height: 300px}
</style>
<body>
<form class="layui-form layui-form-pane" id="operatePage">
    <div class="page-title"><div class="page-title-con"><span>移动至</span><div class="move_title"></div><?php include "../public/sub.php";?></div></div>
    <div class="main-container">
        <div class="layui-form-item">
            <div class="layui-row layui-col-space10">
                <div class="layui-col-md12">
                    <label class="layui-form-label"><text>*</text>文件夹</label>
                    <div class="layui-input-block">
                        <div id="pid"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</form>
<script>
    var param_id = getQueryVariable('id') || 0;

    $("#operatePage").validate({
        rules: {
            name: {required: true},
        },
        messages:{
            name: {required: "请输入"},
        }
    });

    layui.use(['laytp', 'form', 'table'], function() {
        var form = layui.form, layer = layui.layer,table = layui.table;
        render_input_attr();


        facade.ajax({type: 'get', url: ask_engin_fold_move, data:{id:param_id}}).done(function(res){
            if (res.code === 2000) {
                var data = res.data;

                var pidXmObj = xmselect_dan('pid', res.data.foldArr, data.pid, function (res) {
                    if(res.arr && res.arr.length > 0){
                        $("#pid").find('xm-select').removeClass('error');
                    }else{
                        $("#pid").find('xm-select').addClass('error');
                    }
                });

                render_from();
            }
        });


        form.on('submit(add)', function(data){
            var validRes = $("#operatePage").valid();
            if(!data.field.pid){
                $("#pid").find('xm-select').addClass('error');
                validRes = false;
            }else{
                $("#pid").find('xm-select').removeClass('error');
            }
            if(!validRes){return false;}

            data.field.id = param_id;
            facade.ajax({url: ask_engin_fold_move, data:data.field}).done(function(res){
                if (res.code === 2000) {
                    parent.searchTableFunc(form, table);
                    dataPostTimeOut();
                }
            });

            return false;
        });

    });



</script>
</body>
</html>
